using UnityEngine;
using UnityEngine.InputSystem;

public class Lesson15 : MonoBehaviour
{
    public PlayerInput input;
    void Start()
    {
        string json = Resources.Load<TextAsset>("PlayerInputTest").text;
        InputActionAsset asset = InputActionAsset.FromJson(json);
        input.actions = asset;

        input.onActionTriggered += (context) =>
        {
            if (context.phase == InputActionPhase.Performed) {
                switch (context.action.name)
                {
                    case "Move":
                        Debug.LogFormat("移动");
                        break;
                    case "Look":
                        Debug.LogFormat("看向");
                        break;
                    case "Fire":
                        Debug.LogFormat("开火");
                        break;
                }
            }   
        };
    }
}
